/*
 * functors.hpp
 *
 *  Created on: 13 mai 2014
 *      Author: Raphaël
 */

#ifndef FUNCTORS_HPP_
#define FUNCTORS_HPP_

namespace ch
{
namespace raph
{
namespace tools
{
namespace functors
{

struct Identity
    {
    template<typename Type>
    constexpr auto operator()(Type&& value) const noexcept
    -> decltype(std::forward<Type>(value))
        {
        return std::forward<Type>(value);
        }
    };

struct PairFirstValue
    {
    template<class Pair>
    const typename Pair::first_type& operator()(const Pair &value) const
        {
        return value.first;
        }

    template<class Pair>
    typename Pair::first_type& operator()(Pair &value) const
        {
        return value.first;
        }
    };

struct PairSecondValue
    {
    template<class Pair>
    const typename Pair::second_type& operator()(const Pair &value) const
        {
        return value.second;
        }

    template<class Pair>
    typename Pair::second_type& operator()(Pair &value) const
        {
        return value.second;
        }
    };
}
}
}
}
#endif /* FUNCTORS_HPP_ */
